package com.demo.strategy.service;

import com.demo.strategy.adapter.OrderPayPostProcessAdapter;
import com.demo.strategy.holder.OrderPayPostProcessorHolder;
import com.demo.strategy.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderService {

    @Autowired
    private OrderPayPostProcessorHolder orderPayPostProcessorHolder;

    /**
     * 订单支付回调处理
     * @param order
     */
    public void orderPayPostProcess(Order order){
        OrderPayPostProcessAdapter orderPayPostProcessor = orderPayPostProcessorHolder.getOrderPayPostProcessor(order.getOrderType(), order.getChannelTag());
        if (orderPayPostProcessor != null){
            orderPayPostProcessor.orderPayPostProcess(order);
        }
    }
}
